//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Diagnostics;
using OpenLS.Core.Serialization;
using System.Collections.Generic;

namespace OpenLS.Spreadsheet
{
    public class TableStyleElement: IOfficeXmlSerializable
    {
        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read("tableStyleElement"))
            {
                Type = c.GetEnum<TableStyleElementType>("type");
                Size = c.GetOptionalInteger("size", 1);
                int? r = c.GetOptionalInteger("dxfId");
                if (r != null)
                    StyleRecord = c.GetData<DifferentialStyleRecordResolver>()[r.Value];
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("tableStyleElement"))
            {
                c.SetEnum("type", Type);
                c.SetOptionalInteger("size", Size, 1);
                if (StyleRecord != null)
                {
                    int i = context.GetData<WriteObjectTable<DifferentialStyleRecord>>()[StyleRecord];
                    c.SetInteger("dxfId", i);
                }
            }
        }

        #endregion
        private TableStyleElementType tableStyleType;

        public TableStyleElementType Type
        {
            get { return tableStyleType; }
            private set { tableStyleType = value; }
        }
        private int size = 1;

        public int Size
        {
            get { return size; }
            set
            {
                if (value < 0)
                    throw new ArgumentException("value");
                size = value;
            }
        }
        private DifferentialStyleRecord dfx;

        internal DifferentialStyleRecord StyleRecord
        {
            get { return dfx; }
            set
            {
                dfx = value;
            }
        }
	
	
	
    }
}
